package com.yylending.las.personal.loan;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yylending.las.Global;

import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * M:借据
 * Created by ying_he on 2017/6/8.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class DebtEvidenceModel extends Model {
    private static final String TAG = DebtEvidenceModel.class.getSimpleName();

    @Override
    public Observable getObservable(Object params, int functionalCode) {
        Service service = (Service) NetworkHelper.createService(Service.class);
        return service.getDebtEvidence(Global.LOGIN_TOKEN, (RequestParams) params);
    }

    @Override
    public void onNext(Object entity) {
        debtEvidenceResult result = cast(entity);
        EventAgent.post(result);
    }

    private interface Service {
        @POST("server/repay/balanceInfo")
        Observable<debtEvidenceResult> getDebtEvidence(@Header("token") String token, @Body RequestParams params);
    }

    static class RequestParams{
        String loanNo = "";
        String type = "";
    }

    static class debtEvidenceResult extends BaseResultEntity<debtEvidence> {

    }

    static class debtEvidence{
        String businessSum = "";
        String monthPay = "";
        String putOutDate = "";
        String firstRepayDate = "";
        String loanTerm = "";
        String customerName = "";
        String beginDate = "";
        String certId = "";
        String loanCardId = "";
        String loanBank = "";
        String maturityDate = "";
    }
}
